home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / BOOKLIST.AML < prev    next >
Text File  |  1996-07-17  |  4KB  |  164 lines

  1. //--------------------------------------------------------------------
  2. // BOOKLIST.AML
  3. // List all Bookmarks, (C) 1993-1996 by nuText Systems
  4. //
  5. // (See Booklist.dox for user help)
  6. //
  7. // This macro lists all bookmarks in the current edit session. For each
  8. // bookmark, the following data is displayed:
  9. //
  10. //   - bookmark name
  11. //   - filename containing the bookmark
  12. //   - bookmark column
  13. //   - bookmark line
  14. //   - text at the bookmark location
  15. //
  16. // A menu is also displayed which allows you to goto a bookmark, delete a
  17. // bookmark, and delete all bookmarks.
  18. //
  19. // Note: this macro will not handle bookmark names longer than 9 chars.
  20. //
  21. // Usage:
  22. //
  23. // Select this macro from the Macro List (on the Macro menu), or run it
  24. // from the macro picklist <shift f12>.
  25. //--------------------------------------------------------------------
  26.  
  27. include bootpath "define.aml"
  28.  
  29. // initial popup window dimensions
  30. constant book_width  = 68
  31. constant book_height = 13
  32.  
  33. // maximum bookmark name length handled by this macro
  34. constant book_length = 9
  35.  
  36. // colors
  37. constant book_title_color        = color black on gray
  38. constant book_menu_color         = color white on blue
  39. constant book_menu_hotkey_color  = color yellow on blue
  40. constant book_menu_hilite_color  = color white on cyan
  41.  
  42. // temporary bookmark name
  43. constant tempbook = '@T'
  44.  
  45. // inherit from the 'popup' object
  46. settype "popup"
  47.  
  48. // delete bookmark at the cursor
  49. function delbook
  50.   mark = gettext 1 book_length
  51.   if destroybook mark [1 : posnot ' ' mark 'r'] then
  52.     delline
  53.     return 1
  54.   end
  55. end
  56.  
  57. // delete all bookmarks
  58. function delallbook
  59.   row 1
  60.   while delbook do end
  61. end
  62.  
  63. // add a south menu to the popup window
  64. function onopen
  65.   setcolor north_title_color  book_title_color
  66.   setcolor menu_color         book_menu_color
  67.   setcolor menu_hotkey_color  book_menu_hotkey_color
  68.   setcolor menu_hilite_color  book_menu_hilite_color
  69.   setframe "+4"
  70.   menubar '' 4
  71.     item "{Enter}=Goto"             call <enter>
  72.     item "{Del}=Delete"             delbook
  73.     item "{Ctrl-D}=Delete All"      delallbook
  74.     item "{Esc}=Exit"               close
  75.   end
  76.   if (getcoord 'y') + 2 <= getvidrows then
  77.     sizewindow 0 0 0 2
  78.   end
  79.   setwinctrl "≡" 2
  80. end
  81.  
  82. // macro help
  83. macrofile = arg 1
  84. key <f1>
  85.   helpmacro macrofile
  86. end
  87.  
  88. key <del>     delbook
  89. key <ctrl d>  delallbook
  90. end
  91.  
  92. // save the current bufferid
  93. oldbuffer = getcurrbuf
  94. buffer = oldbuffer
  95.  
  96. // create a popup menu buffer
  97. bookbuf = createbuf
  98.  
  99. // cycle through all buffers
  100. while buffer do
  101.  
  102.   // make 'buffer' the current buffer
  103.   gotobuf buffer
  104.  
  105.   // get the top bookmark
  106.   bookmark = getcurrbook
  107.   if bookmark then
  108.  
  109.     tempcursor = createcursor 'TC'
  110.  
  111.     // save the current cursor position and window view in
  112.     // a temporary bookmark (can't use pushcursor because it
  113.     // won't save the window view - gotobook changes the
  114.     // window view)
  115.     setbook tempbook
  116.  
  117.     // cycle through the bookmarks for this buffer
  118.     while bookmark do
  119.       if bookmark <> tempbook then
  120.         // move cursor to the bookmark (and change the window view)
  121.         gotobook bookmark
  122.         addline bookmark:-book_length +
  123.                 (onname (getbufname [1..20]:-20)) + '  ' +
  124.                 ('C' + getcol):-5 + ' ' +
  125.                 ('L' + getrow):-8 + ' ' +
  126.                 (gettext (getlinebeg))
  127.                 '' '' bookbuf
  128.       end
  129.       bookmark = getprevbook bookmark
  130.     end
  131.  
  132.     // restore the cursor position and window view
  133.     // and destroy the temp bookmark
  134.     gotobook tempbook
  135.     destroybook tempbook
  136.     destroycursor tempcursor
  137.   end
  138.   buffer = getprevbuf
  139. end
  140.  
  141. // make the popup menu buffer the current buffer
  142. gotobuf bookbuf
  143.  
  144. if getlines == 1 then
  145.   addline " <no bookmarks found>"
  146. end
  147.  
  148. // delete the first blank line
  149. delline 1 1
  150.  
  151. // sort based on bookmark id
  152. sortblock 'i' '*a'
  153.  
  154. // display the menu
  155. mark = popup bookbuf "Bookmarks"  book_width book_height (getcurrobj)
  156.  
  157. destroybuf bookbuf
  158. gotobuf oldbuffer
  159.  
  160. // goto the bookmark if it was selected
  161. if mark then
  162.   queue "gotobook2" mark [1 : posnot ' ' mark [1:book_length] 'r']
  163. end
  164.